home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Night Owl 6
/
Night Owl's Shareware - PDSI-006 - Night Owl Corp (1990).iso
/
038a
/
aplibs91.zip
/
PWW.BAS
< prev
next >
Wrap
BASIC Source File
|
1991-07-17
|
7KB
|
233 lines
' ┌─────────────────────────────────────────────┐
' │ │
' │ SCREEN CODER -- HB. Started 7-26-87 │
' │ │
' │ CREATES INTERACTIVE DATA ENTRY WINDOWS │
' │ │
' └─────────────────────────────────────────────┘
$COMPILE EXE
$LIB ALL OFF
$ERROR ALL OFF
$OPTION CNTLBREAK ON
DEFINT A-Z
DIM LineBuffer$ (40): DIM FL (40): DIM FC (40)
'
IF INSTR (UCASE$ (COMMAND$), "BATCH") THEN BatchMode = -1
COLOR 9, 0: CLS
Start:
PRINT
LOCATE ,,0
PRINT " CODE GENERATOR FOR POP-WINDOWS IN ";CHR$(34);_
"ALL-PURPOSE LIBRARY"; CHR$(34)
PRINT " Howard Ballinger M.D. 1987 - 91"
PRINT
IF COMMAND$ <> "" THEN
FlNm$ = EXTRACT$ (COMMAND$, " ")
ELSE
IF DIR$ ("*.PW") = "" THEN PRINT "NO FILES MATCHING *.PW FOUND.": END 1
StLn = CSRLIN
FILES "*.PW" ' get a directory ...
PRINT
INPUT "NAME OF WINDOW DESIGN FILE TO PROCESS:"; FlNm$
EndLn = CSRLIN
FOR Y = StLn TO EndLn: LOCATE Y,1: PRINT SPACE$(80);: NEXT
LOCATE StLn, 1
IF FlNm$ = "" THEN PRINT " CANCELLED BY YOUSER.": END
IF INSTR (FlNm$, ".") THEN FlNm$ = LEFT$(FlNm$,(INSTR(FlNm$,".")-1))
END IF
PRINT " ... now writing DATA statements to generate PopWindow ";_
UCASE$ (FlNm$)
PRINT
PRINT "Input file ";UCASE$(FlNm$)+".PW --> Output file ";UCASE$(FlNm$)+".INC";
' file names are now set ...
PRINT ". Reading line ";
L0 = CSRLIN: C0 = POS
IFLine = 1
PRINT
OpenFiles:
IF DIR$ (FlNm$+ ".PW") = "" THEN GOTO NoSuchInputFl
OPEN FlNm$+".PW" FOR INPUT AS 1
OPEN FlNm$+".INC" FOR OUTPUT AS 2
'=========================== START PROCESSING INPUT FILE ======================
SkipBlanks:
L = 0
DO
INCR L: LINE INPUT #1, Nput$ ' skip blank lines
GOSUB Show
IF EOF(1) THEN PRINT "ERROR 1": STOP
LOOP UNTIL Nput$ <> ""
C = 1
' ' take 1st line ...
SearchBox:
DO WHILE LEFT$(Nput$,1) = " " ' chop spaces off left end
Nput$ = MID$(Nput$,2): INCR C ' and count them ...
LOOP
IF LEFT$(Nput$,1) <> "^" THEN
PRINT ">";Nput$;"<"
PRINT "ERROR 2 IN LINE";L;": BOX NOT FOUND":STOP
END IF
' ===================== SET WINDOW DIMENSIONS ================================
CornerCol = C: BoxTop = L ' top of box has been found
Wid = 1: DO UNTIL MID$(Nput$,Wid,1) <> "^": INCR Wid: LOOP ' count carrots ...
DECR Wid,2
O$ = " DATA "+STR$(Wid)+","+STR$(BoxTop)+","+STR$(CornerCol)
LineBuffer$(1) = O$
' ============= PARSE EACH LINE DOWN TO BOXBOTTOM =======================
ParseLines:
N = 2
DO
INCR L: LINE INPUT #1, Nput$
IF EOF(1) THEN PRINT "ERROR -- INPUT FILE INCOMPLETE": STOP
GOSUB Show
TrimLine:
C = 0
' remove blank spaces ...
DO WHILE LEFT$(Nput$,1) = " "
Nput$ = MID$(Nput$,2): INCR C
LOOP
IF LEFT$(Nput$,1) = "^" THEN
Nput$ = MID$(Nput$,2): INCR C ' remove the carrot on the left ...
ELSE
PRINT "ERROR 4: LEFT SIDE OF BOX NOT INTACT": STOP
END IF
Check4Bottom:
IF LEFT$(Nput$,1) = "^" THEN
BoxBottom = L+1 ' check for bottom
ELSE
Check4Fields:
X = 0 ' otherwise find the field locations in the line...
DO
INCR X: INCR C
IF MID$(Nput$,X,1) = "{" THEN ' if a field marker is found
MID$(Nput$,X) = " " ' replace it w/ a space ...
INCR Fld%
FL(Fld%) = L ' and plug its location into
FC(Fld%) = C ' arrays for later use ...
END IF
IF MID$(Nput$,X,1) = "}" THEN MID$(Nput$,X) = " " 'replace } w/ a space ...
LOOP UNTIL X >= LEN(Nput$)
TrimRightEndOff:
DO UNTIL RIGHT$(Nput$,1) <> " " AND RIGHT$(Nput$,1) <> "^"
Nput$ = LEFT$(Nput$,LEN(Nput$)-1)
LOOP
Goob:
C = CornerCol + 1 ' Since the carrot has been trimmed off, that's
' where the placement of what's left of Nput$
' will start on screen ...
DO UNTIL LEFT$ (Nput$,1) <> " "
Nput$ = MID$(Nput$,2)
INCR C
LOOP
IF Nput$ <> "" THEN
LineBuffer$ (N) = " DATA " + CHR$(34) + Nput$ + CHR$(34) + ","_
+ STR$(L) + "," + STR$(C)
INCR N
END IF
END IF
LOOP UNTIL BoxBottom
' ============== WRITE TO TARGET FILE =================
WriteLns:
PRINT #2, "' Begin PopWindow data for window {";FlNm$;"}"
PRINT #2, "' note: created by PopWindow Writer (PWW) from ";FlNm$;".PW"
PRINT #2, ""
LineBuffer$(1) = LineBuffer$(1)+","+STR$(BoxBottom - BoxTop)
' and write first line of code
N = 1
DO UNTIL LineBuffer$(N) = ""
PRINT #2, LineBuffer$(N)
INCR N
LOOP
PRINT #2, " DATA END"
' ===================== READ FIELD DATA =====================
ReadFldData:
PartTwo:
PRINT #2, ""
Fld% = 0
DO
LINE INPUT #1,Nput$
GOSUB Show
LOOP UNTIL LEFT$(Nput$,1) = "\"
WritePtII:
DO
LINE INPUT #1,Nput$
GOSUB Show
IF Nput$ <> "" AND LEFT$(Nput$,1) <> " " THEN
INCR Fld%
O$ = " DATA "+Nput$+","+STR$(FL(Fld%))+","+STR$(FC(Fld%))
PRINT #2, O$
END IF
LOOP UNTIL EOF(1)
Report$ = " DONE, NO ERRORS -- OK"
IF FL(Fld%) = 0 THEN_
Report$ = "DONE. INPUT FILE ERROR -- TOO MANY FIELDS NAMED."
INCR Fld%
IF FL(Fld%) <> 0 THEN_
Report$ = "DONE. INPUT FILE ERROR -- TOO MANY FIELD LOCATION"+_
" MARKERS ({) IN DESIGN."
PRINT #2, " DATA END"
Print #2, ""
PRINT #2, "' ";DATE$;", ";LEFT$(TIME$,5);_
": end of PopWindow data for window {";FlNm$;"}"
CLOSE
PRINT: PRINT " "; Report$
IF Report$ <> " DONE, NO ERRORS -- OK" THEN
PLAY "O3 B8 P8 G4"
DO: LOOP UNTIL INKEY$ <> ""
END IF
END
' <<<<<<<<<<<<<<<<>>>>>>>>>>>>>>>>>>>>>
QT:
STOP
RETURN
NoSuchInputFl:
PRINT:PRINT:PRINT " ERROR -- Input File ";FlNm$;".PW not found"
PRINT: END 1
Show:
LOCATE L0, C0, 0
PRINT USING "###"; IFLine
INCR IFLine
PRINT
RETURN